home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / timer.h < prev    next >
C/C++ Source or Header  |  1999-12-17  |  2KB  |  61 lines

  1. /***************************************************************************
  2.  
  3.   timer.c
  4.  
  5.   Functions needed to generate timing and synchronization between several
  6.   CPUs.
  7.  
  8. ***************************************************************************/
  9.  
  10. #ifndef __TIMER_H__
  11. #define __TIMER_H__
  12.  
  13. extern double cycles_to_sec[];
  14. extern double sec_to_cycles[];
  15.  
  16. #define TIME_IN_HZ(hz)        (1.0 / (double)(hz))
  17. #define TIME_IN_CYCLES(c,cpu) ((double)(c) * cycles_to_sec[cpu])
  18. #define TIME_IN_SEC(s)        ((double)(s))
  19. #define TIME_IN_MSEC(ms)      ((double)(ms) * (1.0 / 1000.0))
  20. #define TIME_IN_USEC(us)      ((double)(us) * (1.0 / 1000000.0))
  21. #define TIME_IN_NSEC(us)      ((double)(us) * (1.0 / 1000000000.0))
  22.  
  23. #define TIME_NOW              (0.0)
  24. #define TIME_NEVER            (1.0e30)
  25.  
  26. #define TIME_TO_CYCLES(cpu,t) ((int)((t) * sec_to_cycles[cpu]))
  27.  
  28.  
  29. #define SUSPEND_REASON_HALT        0x0001
  30. #define SUSPEND_REASON_RESET    0x0002
  31. #define SUSPEND_REASON_SPIN        0x0004
  32. #define SUSPEND_REASON_TRIGGER    0x0008
  33. #define SUSPEND_REASON_DISABLE    0x0010
  34. #define SUSPEND_ANY_REASON        ((UINT32)-1)
  35.  
  36.  
  37. void timer_init(void);
  38. void *timer_pulse(double period, int param, void(*callback)(int));
  39. void *timer_set(double duration, int param, void(*callback)(int));
  40. void timer_reset(void *which, double duration);
  41. void timer_remove(void *which);
  42. int timer_enable(void *which, int enable);
  43. double timer_timeelapsed(void *which);
  44. double timer_timeleft(void *which);
  45. double timer_get_time(void);
  46. double timer_starttime(void *which);
  47. double timer_firetime(void *which);
  48. int timer_schedule_cpu(int *cpu, int *cycles);
  49. void timer_update_cpu(int cpu, int ran);
  50. void timer_suspendcpu(int cpu, int suspend, int reason);
  51. void timer_holdcpu(int cpu, int hold, int reason);
  52. int timer_iscpususpended(int cpu, int reason);
  53. int timer_iscpuheld(int cpunum, int reason);
  54. void timer_suspendcpu_trigger(int cpu, int trigger);
  55. void timer_holdcpu_trigger(int cpu, int trigger);
  56. void timer_trigger(int trigger);
  57. double timer_get_overclock(int cpunum);
  58. void timer_set_overclock(int cpunum, double overclock);
  59.  
  60. #endif
  61.